using System;
using System.Xml.Linq;

namespace unTroublemaker.Parsing
{
    public class ParseException : Exception
    {
        public ParseException(XElement element, string message, Exception e) : base(GetMessage(element, message), e) { }

        public ParseException(XElement element, string message) : base(GetMessage(element, message)) { }

        public ParseException(string message) : base(message) { }

        private static string GetMessage(XElement element, string message)
        {
            return "Failed to parse node <" + element.Name.LocalName + "> at " + element.LineNo() + ": " + message;
        }
    }
}